<template>
	<view class="main">
		<view class="content">
			<view class="head">
				<view class="list-content" v-for="(item, index) in list1" v-if="index == 0" @tap="goDetail(item)">
					<view class="left">
						<image :src="item.icoImg" mode="" class="header-img"></image>
					</view>
					<view class="right">
						<view class="des">
							{{item.name}}
						</view>
						<view class="rate">
							<!-- <u-rate size="20" disabled gutter='5' :count="count" v-model="item.star" active-color="#FFD100" inactive-color="#FFD100"></u-rate> -->
							<u-rate active-color="#FFD100" size="32" :current="item.score * 0.5" :disabled="true">
							</u-rate>
							<text>{{ item.score }}</text>
						</view>
						<view class="des">类型：{{ item.movieType }}</view>
						<view class="des">导演：{{ item.director }}</view>
						<view class="des">主演：{{ item.leaders }}</view>
						<view class="des">上映日期：{{ item.starttime }}</view>
					</view>

				</view>
			</view>

			<view class="content1">
				<view v-for="(item, index) in list1 " class="list1" @tap="goDetail(item)" v-if="index > 0">
					<image :src="item.icoImg" mode="" class="img1" mode="widthFix"></image>
					<view class="title">{{item.name}}</view>
					<!-- <view class="des1">影院: {{item.cinema_name}}</view> -->
					<!-- <u-rate active-color="#FFD100" size="24" :current="3" :disabled="true"></u-rate> -->
				</view>
			</view>
			<!-- <view style="height: 40rpx;"></view> -->

		</view>
		<view class="loadmore">
			<u-loadmore :status="status" />
		</view>
		<Nav :current='navActive'></Nav>
		<backAins :type="11" v-if="fros.sin==1"></backAins>
	</view>

</template>

<script>
	import backAins from '../../component/backAins.vue'
	import Nav from '../../component/Nav.vue'
	export default {
		components: {
			Nav,
			backAins
		},
		data() {
			return {
				status: 'loadmore',
				rejectShow: false,
				action: 'http://www.example.com/upload',
				list1: [],
				pageNum: 1, //当前页码
				pageSize: 10, //每页数量
				navActive: 2,
				fros: {
					sin: 0
				},
				uid: '',
			}
		},
		onLoad(e) {
			if (e.userId) {
				uni.setStorageSync('InvitedCode', e.userId)
			}
			this.uid = uni.getStorageSync('userInfo').id
		},
		onShow() {
			this.pageNum = 1;
			uni.removeStorageSync('actId');
			// try {
			// 	const value = uni.getStorageSync('userInfo') || {
			// 		token: 1
			// 	};
			// 	if (value) {
			// 		const token = uni.getStorageSync('token') || 1
			// 		this.header = {
			// 			"token": token
			// 		}

			// 		this.uid = value.id
			// 	}
			// } catch (e) {
			// 	// error
			// }
			this.action = this.$api.fileUpload
			this.getInfo()

			if (this.uid != undefined) {
				this.getredin();
			}

		},
		onPullDownRefresh() {
			this.list1 = []
			this.getInfo()
			if (this.uid != undefined) {
				this.getredin();
			}
		},
		// 加载更多
		onReachBottom() {
			console.log(123)
			if (Math.ceil(this.total / this.pageSize) > this.pageNum) {
				this.pageNum = this.pageNum + 1;
				this.getInfo();
			} else {}
		},

		methods: {
			getredin() {
				uni.stopPullDownRefresh();
				this.status = 'loading'
				this.$http({
					url: this.$api.selectIsRead,
					method: 'GET',
					hideLoading: true,
					data: {
						uid: this.uid,
					},
					success: res => {
						if (res.data.gyReport == 0 && res.data.mvApt == 0 && res.data.mvDec == 0 && res.data
							.mvBaochang == 0 && res.data.spOrderList == 0&&res.data.uniPushUser==0) {
							this.fros.sin = 2
						} else {
							this.fros.sin = 1
						}
					},
				})
			},
			getInfo() {
				this.status = 'loading';
				this.$http({
					url: this.$api.getXyMovieList,
					method: 'GET',
					hideLoading: true,
					data: {
						pageNum: this.pageNum,
						pageSize: this.pageSize,
						xyflag: 0,
					},
					success: res => {
						if (res.ext != 0) {
							this.getList();
						} else {
							this.status = 'nomore';
						}
						// this.list1 = res.data;
						// this.status = 'nomore';
					},
					fail: err => {
						this.status = 'nomore';
					},
					complete: e => {
						uni.stopPullDownRefresh();
						this.status = 'nomore';
					}
				})
				uni.stopPullDownRefresh();
			},
			// 获取电影列表
			getList() {
				this.status = 'loading';
				this.$http({
					url: this.$api.getXyMovieList,
					method: 'GET',
					hideLoading: true,
					data: {
						pageNum: this.pageNum,
						pageSize: this.pageSize,
						xyflag: 0,
					},
					success: res => {
						console.log(res);

						this.total = Number(res.ext);
						if (Math.ceil(this.total / this.pageSize) <= this.pageNum) {
							this.status = 'nomore';
						} else {
							this.status = 'loadmore';
						}
						if (this.pageNum == 1) {
							this.list1 = res.data
						} else {
							this.list1 = this.list1.concat(res.data);
						}
						this.list1.sort((a, b) => {
							if (a.sort == b.sort) {
								return a.starttime - b.starttime;
							} else {
								return a.sort - b.sort
							}

						});

						console.log(this.list1)

						this.ext = res.ext;
					},
					fail: err => {
						this.status = 'nomore';
					},
					complete: e => {
						uni.stopPullDownRefresh();
						this.status = 'nomore';
						// if (!e.code) {
						// this.status = 'nomore';
						// }
					}
				});
			},


			goDetail(row) {
				console.log(row);
				console.log(111111111111)
				let data = {
					id: row.id,
					name:row.name,
					icoImg:row.icoImg,
					star:row.star
				}
				uni.navigateTo({
					url: '/pages/FilmReport/index?data=' + JSON.stringify(data)
				})
			},
			// 显示驳回原因
			showReject() {
				this.rejectShow = !this.rejectShow;
			},
			// 获取信息

			// 跳转包场照片详情页
			goPhotoDetails(item) {
				uni.navigateTo({
					url: '/pages/phoneDetail/phoneDetail'
				})
			},



		}
	}
</script>

<style lang="less" scoped>
	.content {}

	.title {
		font-size: 32rpx;
		font-weight: bold;
		// line-height: 44rpx;
	}

	.head {
		.list-content {

			display: flex;
			flex-direction: row;
			font-size: 28rpx;
			padding: 24rpx;
			padding-bottom: 0rpx;
			color: #333;
			padding-top: 0rpx;
			background-color: #423933;
			color: #fff;
			padding-bottom: 20rpx;
			padding-top: 16rpx;
			height: 340rpx;

			.left {
				text-align: center;

				.header-img {
					width: 226rpx;
					height: 315rpx;
					border-radius: 8rpx;
				}

				margin-right: 20rpx;
			}

			.right {
				width: 65%;

				.des {
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					font-size: 28rpx;
					font-weight: 400;
					color: #eee;
					line-height: 54rpx;
				}

				.des:last-child {
					margin-bottom: 18rpx;
				}

				.btn {
					color: #fff;
					width: fit-content;
					padding: 8rpx 24rpx;
					text-align: center;
					border-radius: 8rpx;
					margin-top: 38rpx;
					// width: 164rpx;
					// height: 52rpx;
					background: #DC4C41;
					opacity: 1;
					font-size: 24rpx;

				}
			}

			.right-list {
				padding-left: 48rpx;

				.label {
					margin-right: 40rpx
				}
			}
		}

	}

	.des1 {
		font-size: 24rpx;
		color: #707070;
		width: 50%;
	}

	.list {
		display: flex;

		.des {
			font-size: 24rpx;
			color: #707070;
			width: 50%;
		}
	}

	.content1 {
		display: flex;
		flex: 1 0;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 32rpx 24rpx;

		.img1 {
			width: 94%;
			// max-height: 452rpx;
			background: rgba(0, 0, 0, 0);
			opacity: 1;
			border-radius: 12rpx;
		}

		.list1 {
			width: 48%;
			// width: 208rpx;
			// height: 342rpx;
			background: #FFFFFF;
			box-shadow: 0px 4rpx 10rpx rgba(0, 0, 0, 0.12);
			opacity: 1;
			border-radius: 12rpx;
			margin-bottom: 40rpx;
			padding-bottom: 10rpx;
			text-align: center;
			// padding: 20rpx 20rpx;
			padding-top: 12rpx;
			box-sizing: border-box;

		}

		.title {
			font-size: 28rpx;
			// padding-left: 20rpx;
			// text-align: left;
		}
	}
</style>
